﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TimeManager : MonoBehaviour {

    public Text TimeText;
    int TotalTime=180;
    private int minute;
    private int second;
    private float timer;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        /*time -= Time.deltaTime;
        TimeText.text = "Time<color=yellow>:" + time + "</color>";*/
        timer += Time.deltaTime;
        if(timer>1.0f)
        {
            TotalTime--;
            timer = 0;
        }
        //TimeText.text = "Time:" + TotalTime;
        if (TotalTime <= 0)
        {
            Debug.Log("Pause");
        }
        minute = TotalTime / 60;
        second = TotalTime % 60;
        //string length = minute.ToString();
        if (second >= 10)
        {
            TimeText.text = "0" + minute + ":" + second;
        }
        else
            TimeText.text = "0" + minute + ":0" + second;
    }

    public IEnumerator startTime()
    {
        while(TotalTime>=0)
        {
            yield return new WaitForSeconds(1);



        }
    }
}

